﻿namespace ProcessManager
{
    using System.Linq;

    internal class ProcessManagerEngine
    {
        #region Fields

        private System.TimeSpan _recordingProcessTimeSpan = new System.TimeSpan(0, 10, 0);
        private string _recordingFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);//System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(ProcessManagerEngine)).CodeBase);

        #endregion

        #region Methods

        internal void Run()
        {
            while (System.Threading.Thread.CurrentThread.IsAlive)
            {
                System.IO.File.AppendAllLines(System.IO.Path.Combine(_recordingFilePath, "ess.txt"), System.Diagnostics.Process.GetProcesses().Select(p => p.ProcessName));

                System.Threading.Thread.Sleep(this._recordingProcessTimeSpan);
            }
        }

        #endregion
    }
}
